package com.example.basic.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author mjw
 * @date 2022/8/26
 */
@Configuration
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.OAS_30)
                .groupName("Time_01-ekko")
                .select()
                //指定扫描的包路径
                .apis(RequestHandlerSelectors.basePackage("com.example.basic.controller"))
                .build()
                .apiInfo(createApiInfo())
                //是否开启Swagger
                .enable(true)
                ;
    }

    @Bean
    public ApiInfo createApiInfo() {
        return new ApiInfo("自定义的Swagger文档",
                "Time Api Document",
                "3.0",
                "http://www.time.com",
                new Contact("时光","时光","时光"),
                "Apache 2.0",
                "http://www.time.com",
                new ArrayList<>());
    }
}
